package ex3.controller.date.ccf;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;

/**
 * @AUTHOR 尹书岿
 * @DATE 2024/12/11 16:08
 * @DESCRIBE
 */
public class Date {

    static int mm[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
    static boolean isLeapYear(int year) {
        return year % 400 == 0 || year % 4 == 0 && year % 100 != 0;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int y1 = sc.nextInt();
        int y2 = sc.nextInt();

        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd");
        for ( int i = y1; i < y2 ; i++){
            String str = String.format("%d/%02d/%02d",i,a,1);
            LocalDate ld = LocalDate.parse(str,dtf);
            int cc = ld.getDayOfWeek().getValue();
            mm[2] = ld.isLeapYear() ? 29:28;


            int count = 0;
            int k = 1 + (c + 7 - cc);
            if(k > 7) {
                k -= 7;
            }
            while(k <= mm[a]){
                count++;
                if (count == b){
                    System.out.println(String.format("%d/%02d/%02d",i,a,k));
                    break;
                }
                k += 7;
            }
            if (k > mm[a]){
                System.out.println("none");
            }
        }


    }
}
